<template>
    <div class="news">
        <ul>
            <li v-for="item in newList" :key="item.id">
                <button @click="showDetail(item)">点我查看详情</button>
                <RouterLink :to="{
                    name: 'xiang',
                    query: {
                        id: item.id,
                        title: item.title,
                        content: item.content
                    }
                }">{{ item.title }}
                </RouterLink>

            </li>
        </ul>
        <div class="news-content">
            <RouterView/>
        </div>
    </div>
</template>

<script setup lang="ts" name="News">
import {reactive} from "vue";
import {useRouter} from "vue-router";
let router = useRouter()

const newList = reactive([
    {id: 'fjlafjl001', title: '三国演义', content: '曹操'},
    {id: 'fjlafjl002', title: '西游记', content: '孙悟空'},
    {id: 'fjlafjl003', title: '红楼梦', content: '宝玉'}
])

function showDetail(item) {
    // 注意： push，replace    to怎么写，push里面就怎么写
    router.push({
        name: 'xiang',
        query: {
            id: item.id,
            title: item.title,
            content: item.content
        }
    })
}
</script>

<style scoped>
/* 新闻 */
.news {
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    height: 100%;
}

.news ul {
    margin-top: 30px;
    list-style: none;
    padding-left: 10px;
}

.news li > a {
    font-size: 18px;
    line-height: 40px;
    text-decoration: none;
    color: #64967E;
    text-shadow: 0 0 1px rgb(0, 84, 0);
}

.news-content {
    width: 70%;
    height: 90%;
    border: 1px solid;
    margin-top: 20px;
    border-radius: 10px;
}
</style>
